/**
 * 用于将EditBox上的节点在该EditBox获取焦点的时候闪烁
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class EditBoxIndicatorTs extends cc.Component {

    @property(cc.Node)
    indicator: cc.Node = null;

    @property(cc.EditBox)
    editBox : cc.EditBox = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        var clickEventHandler = new cc.Component.EventHandler();
        clickEventHandler.target = this.node; //这个 node 节点是你的事件处理代码组件所属的节点
        clickEventHandler.component = "EditBoxIndicatorTs";//这个是代码文件名
        clickEventHandler.handler = "showIndicator";
        // clickEventHandler.customEventData = "foobar";
        this.editBox.editingDidBegan.push(clickEventHandler)


        var clickEventHandler2 = new cc.Component.EventHandler();
        clickEventHandler2.target = this.node; //这个 node 节点是你的事件处理代码组件所属的节点
        clickEventHandler2.component = "EditBoxIndicatorTs";//这个是代码文件名
        clickEventHandler2.handler = "stopIndicator";
        this.editBox.editingDidEnded.push(clickEventHandler2)
    }

    start () {

    }

    update (dt) {

    }

    showIndicator(){
        var fadeIn1 = cc.fadeIn(0.4)
        var fadeOut1 = cc.fadeOut(0.4)
        let seq1 = cc.sequence(fadeOut1,fadeIn1)
        let repeat1 = cc.repeatForever(seq1)
        this.indicator.runAction(repeat1)
    }

    stopIndicator(){
        this.indicator.stopAllActions()
        this.indicator.opacity = 255;
    }
}
